/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package pe.edu.pucp.dp1.lectura.controlador;

import Shared.FileCar;
import Shared.ObjCar;
import java.io.File;
import java.util.ArrayList;

/**
 *
 * @author ed
 */
public class HiloLectorFiles extends Thread {
    
    public GestorCar gestorInstance = GestorCar.getInstance();
    private int iniIntervalHilo;
    private ArrayList<File> filesAcargar = null;

    public HiloLectorFiles(int limiteIntervalo,ArrayList<File> fileList) {
        setIniIntervalHilo(limiteIntervalo);
        setFilesAcargar(fileList);
    }
    
    public void run() {
        int seg = 0;
        int saltoHilo = gestorInstance.getIntervalHilo();
        int iniInterval = getIniIntervalHilo();
        int iniSgteInterval = iniInterval + 1;
        int totCars = gestorInstance.getListCarSimu().size();
            try {
                for (int i = (iniInterval * saltoHilo); (i < (iniSgteInterval * saltoHilo) && (i < totCars)); i++) {
                    FileCar carro = new FileCar(getFilesAcargar().get(i));
                    gestorInstance.getListCarSimu().add(new ObjCar(carro.getPlaca()));
                    
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
            seg++;

        }
    

    /**
     * @return the iniIntervalHilo
     */
    public int getIniIntervalHilo() {
        return iniIntervalHilo;
    }

    /**
     * @param iniIntervalHilo the iniIntervalHilo to set
     */
    public void setIniIntervalHilo(int iniIntervalHilo) {
        this.iniIntervalHilo = iniIntervalHilo;
    }

    /**
     * @return the filesAcargar
     */
    public ArrayList<File> getFilesAcargar() {
        return filesAcargar;
    }

    /**
     * @param filesAcargar the filesAcargar to set
     */
    public void setFilesAcargar(ArrayList<File> filesAcargar) {
        this.filesAcargar = filesAcargar;
    }
    
}
